# Set d=Server.CreateObject("Scripting.Dictionary")
# Set t=Server.CreateObject("Scripting.Dictionary")
# d.Add "wtr_name","委托人"
# t.Add "wtr_name",false
# d.Add "bwtr_name","被委托人"
# t.Add "bwtr_name",false
# d.Add "category_name","类型"
# t.Add "category_name",false
# d.Add "cd_no","报关单号"
# t.Add "cd_no",false
# d.Add "cd_date","申报日期"
# t.Add "cd_date",false
# d.Add "cd_company","企业名称"
# t.Add "cd_company",false
# d.Add "cd_voyage","船名/航次"
# t.Add "cd_voyage",false
# d.Add "cd_lading","提单号"
# t.Add "cd_lading",false
# d.Add "cd_verify","核销单号"
# t.Add "cd_verify",false
# d.Add "cd_passno","通关单号"
# t.Add "cd_passno",false
# d.Add "cd_orderno","订单号"
# t.Add "cd_orderno",false
# d.Add "cd_boxno","箱号"
# t.Add "cd_boxno",false
# d.Add "cd_receive","报关费(应收)"
# t.Add "cd_receive",true
# d.Add "cd_pay","报关费(应付)"
# t.Add "cd_pay",true
# d.Add "cy_receive","查验(应收)"
# t.Add "cy_receive",true
# d.Add "cy_pay","查验(应付)"
# t.Add "cy_pay",true
# d.Add "sj_receive","商检(应收)"
# t.Add "sj_receive",true
# d.Add "sj_pay","商检(应付)"
# t.Add "sj_pay",true
# d.Add "jk_receive","进口(应收)"
# t.Add "jk_receive",true
# d.Add "jk_pay","进口(应付)"
# t.Add "jk_pay",true
# d.Add "qt_receive","其他(应收)"
# t.Add "qt_receive",true
# d.Add "qt_pay","其他(应付)"
# t.Add "qt_pay",true
# d.Add "total_receive","合计(应收)"
# t.Add "total_receive",true
# d.Add "total_pay","合计(应付)"
# t.Add "total_pay",true
# d.Add "cd_actreceive","实际(已收)"
# t.Add "cd_actreceive",true
# d.Add "cd_actpay","实际(已付)"
# t.Add "cd_actpay",true
# d.Add "cd_memo","备注"
# t.Add "cd_memo",false

# '错误信息
# Set dError=Server.CreateObject("Scripting.Dictionary")
# dError.add "1","未找到数据"
# dError.add "2","没有权限"
# dError.add "3","没有登录"

# '表格信息
# Set dTable=Server.CreateObject("Scripting.Dictionary")
# dTable.add "cd","报关单"
# dTable.add "file","海关原始单"
# dTable.add "username","用户"

# '核销单状况
# Set dStatus=Server.CreateObject("Scripting.Dictionary")
# dStatus.add "1","未退"
# dStatus.add "2","海关已退"
# dStatus.add "3","已退客户"

# '是否
# Set dBool=Server.CreateObject("Scripting.Dictionary")
# dBool.add "True","是"
# dBool.add "False","否"

# ' 权限字典
# Set dAuthority=Server.CreateObject("Scripting.Dictionary")
# dAuthority.add "1","查询"
# dAuthority.add "2","查询、查看"
# dAuthority.add "3","查询、查看、添加"
# dAuthority.add "4","查询、查看、添加、编辑"
# dAuthority.add "5","查询、查看、添加、编辑、删除"
# dAuthority.add "15","管理员"

# Set dCdTable=Server.CreateObject("Scripting.Dictionary")
# dCdTable.add "wtr_name","委托人"
# dCdTable.add "bwtr_name","被委托人"
# dCdTable.add "category_name","类型"
# dCdTable.add "cd_no","报关单号"
# dCdTable.add "cd_date","申报日期"
# dCdTable.add "cd_company","企业名称"
# dCdTable.add "cd_voyage","船名航次"
# dCdTable.add "cd_lading","提单号"
# dCdTable.add "cd_verify","核销单号"
# dCdTable.add "cd_passno","通关单号"
# dCdTable.add "cd_orderno","订单号"
# dCdTable.add "cd_boxno","箱号"
# dCdTable.add "cd_memo","备注"
# dCdTable.add "cd_status","核销单状况"
# dCdTable.add "cd_statusdate","核销单日期"
# dCdTable.add "cd_confirm","确认"
# dCdTable.add "cd_receive","报关费(应收)"
# dCdTable.add "cd_pay","报关费(应付)"
# dCdTable.add "total_receive","合计(应收)"
# dCdTable.add "total_pay","合计(应付)"
# dCdTable.add "cd_actreceive","实际(已收)"
# dCdTable.add "cd_actpay","实际(已付)"
# dCdTable.add "post","岗位"



# '代替ASP中的Request函数，可以对一切的SQL注入Say NO
# Function SafeRequest(ParaName,ParaType)
# '--- 传入参数 ---
# 'ParaName:参数名称-字符型
# 'ParaType:参数类型-数字型(1表示以上参数是数字，0表示以上参数为字符)
  # Dim ParaValue
  # ParaValue=Request(ParaName)
  # If ParaType=1 then
    # If Not IsNumeric(ParaValue) then
      # Response.Write "参数" & ParaName & "必须为数字型！"
      # Response.End
    # End If
  # Else
    # ParaValue=Replace(ParaValue,"'","''")
  # End If
  # SafeRequest=ParaValue
# End Function

# function ULen(byval str)
  # Dim RegExpObj,ReGCheck
  # Set RegExpObj=new RegExp
  # RegExpObj.Pattern="^[\u4e00-\u9fa5|\uFF00-\uFFFF]+$"
  # Dim l,t,c,i
  # l=Len(str)
  # t=l
  # For i=1 to l
    # c=Mid(str,i,1)
    # ReGCheck=RegExpObj.test(c)
    # If ReGCheck Then
      # t=t+1
    # End If
  # Next
  # Set RegExpObj=nothing
  # ULen=t
# end function

# function FillSpace(str,len)
  # dim i,u
  # u=ULen(str)
  # if u<len then
    # for i=1 to len-u
      # str=str&"&nbsp;"
    # next
  # end if
  # FillSpace=str
# end function

# '执行command对象函数，sql_text为要执行的sql语句，return_id为是否要返回insert后的自动编号
# function ExecuteCommand(sql_text,return_id)
  # dim last_id,cmd,rs_last
  # set cmd=Server.CreateObject("ADODB.Command")
  # cmd.ActiveConnection = conn
  # cmd.CommandText = sql_text
  # ' response.write(sql_text)
  # ' response.end
  # cmd.Execute
  # if lcase(left(ltrim(sql_text),6))="insert" and return_id then
    # cmd.CommandText = "select @@IDENTITY"
    # set rs_last=cmd.Execute
    # last_id=rs_last.getstring
    # rs_last.close
    # set rs_last=nothing
  # end if
  # set cmd=nothing
  # ExecuteCommand=last_id
# end function




# '检查登录用户是否在这个岗位
# function CheckPost(aaTemp,iPost)
  # dim i
  # CheckPost=false
  # if iPost="" then exit function
  # if not IsArray(aaTemp) then exit function
  # for i=0 to ubound(aaTemp,2)
    # if aaTemp(0,i)=cint(iPost) then
      # CheckPost=true
      # exit function
    # end if
  # next
# end function

# '检查登录用户是否有权限，只要有任何一个岗位低于iFlag，就返回false
# function CheckFlag(aaTemp,iFlag)
  # dim i
  # CheckFlag=false
  # if not CheckLogin() then
    # call JumpErrorPage(3)
    # exit function
  # end if
  # if iFlag="" then exit function
  # if not IsArray(aaTemp) then exit function
  # for i=0 to ubound(aaTemp,2)
    # if aaTemp(1,i)<cint(iFlag) then exit function
  # next
  # CheckFlag=true
# end function

# '检查登录用户是否有某个岗位的某个权限
# function CheckPostFlag(aaTemp,iPost,iFlag)
  # CheckPostFlag=false
  # if not CheckLogin() then
    # call JumpErrorPage(3)
    # exit function
  # end if
  # if iPost="" or iFlag="" then exit function
  # if not IsArray(aaTemp) then exit function
  # if GetFlagValue(aaTemp,iPost)>=cint(iFlag) then
    # CheckPostFlag=true
  # end if
# end function

# '获取某个岗位的权限
# function GetFlagValue(aaTemp,iPost)
  # dim i
  # GetFlagValue=0
  # if iPost="" then exit function
  # if not IsArray(aaTemp) then exit function
  # for i=0 to ubound(aaTemp,2)
    # if aaTemp(0,i)=cint(iPost) then
      # GetFlagValue=cint(aaTemp(1,i))
      # exit function
    # end if
  # next
# end function

# '获得权限的中文字符
# ' function GetFlagString(iFlag)
  # ' select case iFlag
    # ' case 1 GetFlagString="查询"
    # ' case 2 GetFlagString="查询、查看"
    # ' case 3 GetFlagString="查询、查看、添加"
    # ' case 4 GetFlagString="查询、查看、添加、编辑"
    # ' case 5 GetFlagString="查询、查看、添加、编辑、删除"
    # ' case 15 GetFlagString="管理员"
    # ' case else GetFlagString=""
  # ' end select
# ' end function

# '获得岗位的中文字符
# ' function GetPostString(iPost)
  # ' select case iPost
    # ' case 0 GetPostString="用户权限"
    # ' case 1 GetPostString="输入"
    # ' case 2 GetPostString="作业"
    # ' case 3 GetPostString="审核"
    # ' case 4 GetPostString="财务"
    # ' case 5 GetPostString="核销单管理"
    # ' case else GetPostString=""
  # ' end select
# ' end function



# '获得岗位的中文字符
# function GetPostString(aaTemp,iPost)
  # dim i
  # GetPostString=""
  # if not IsArray(aaTemp) then exit function
  # for i=0 to ubound(aaTemp,2)
    # if aaTemp(0,i)=cint(iPost) then
      # GetPostString=aaTemp(1,i)
      # exit function
    # end if
  # next
# end function


# '判断是否是：不等于空字符串并且不等于0的数字
# function IsNumberNz(s)
  # IsNumberNz=false
  # if IsNumeric(s) then
    # if s<>"" and s<>0 then
      # IsNumberNz=true
    # end if
  # end if
# end function


# '跳转到错误页面，id是错误编号，url是跳转前的页面地址
# function JumpErrorPage(iError)
  # dim oldurl
  # oldurl="http://"&request.ServerVariables("HTTP_HOST")&request.ServerVariables("Url")
  # if request.ServerVariables("QUERY_STRING")<>"" then oldurl=oldurl&"?"&request.ServerVariables("QUERY_STRING")
  # response.redirect("error.asp?id="&iError&"&url="&Server.URLEncode(oldurl))
# end function

# function ShowError(iError)
  # response.write("错误："&dError(cstr(iError)))
  # response.end
# end function

# function CheckLogin()
  # CheckLogin=false
  # if session("sSystem")="yongding" and session("bLogin")=true then CheckLogin=true
# end function
so=Session()
def CheckLogin():
    if (not hasattr(so, 'sSystem')) and (not hasattr(so, 'bLogin')):
        return False
    else:
        return True

# ' function CheckLogin_Wtr()
  # ' CheckLogin_Wtr=false
  # ' if session("sSystem")="yongding" and session("bLogin")=true and session("bEmployee")=false then CheckLogin_Wtr=true
# ' end function

# function CheckWtr()
  # if not session("bEmployee") then CheckWtr=true else CheckWtr=false
# end function

# function CheckEmployee()
  # if session("bEmployee") then CheckEmployee=true else CheckEmployee=false
# end function

# ' 判断用户访问的httphost地址，因为如果判断用户ip，可能是用vpn拨号进来的，那就可能是10.8.2这段，会误判
# function CheckLan()
  # CheckLan=false
  # if request.ServerVariables("HTTP_HOST")="192.168.0.253" or request.ServerVariables("HTTP_HOST")="127.0.0.1" or request.ServerVariables("HTTP_HOST")="localhost" then CheckLan=true
# end function


# function CheckPassword(sPassword)
  # CheckPassword=false
  # Dim RegExpObj
  # Set RegExpObj=new RegExp
  # RegExpObj.Pattern="^(?![^a-zA-Z]+$)(?!\D+$).{6,10}$"
  # CheckPassword=RegExpObj.test(sPassword)
  # Set RegExpObj=nothing
# end function

# function OperateClient(iUser)
  # dim rs_client,sql_client
  # set rs_client=server.createobject("adodb.recordset")
  # sql_client="select * from client where clientip='"&Request.ServerVariables("remote_addr")&"' and clientagent='"&Request.ServerVariables("http_user_agent")&"'"
  # if iUser="null" then sql_client=sql_client&" and username is null" else sql_client=sql_client&" and username="&iUser
  
  # rs_client.open sql_client,conn,1,1
  # if not rs_client.eof and not rs_client.bof then
    # OperateClient=rs_client("id")
  # else
    # OperateClient=ExecuteCommand("insert into client(username,clientip,clienthost,clientagent) values("&iUser&",'"&Request.ServerVariables("remote_addr")&"','"&Request.ServerVariables("remote_host")&"','"&Request.ServerVariables("http_user_agent")&"')",true)
  # end if
  # rs_client.close
  # set rs_client=nothing
# end function


# function SimpleRecord(re_table,re_id,re_operate,re_memo,username,re_clientid,return_id)
  # dim sql
  # ' if re_id="null" then sql="insert into record(re_table,re_operate,re_memo,username,re_clientid) values('"&lcase(re_table)&"','"&re_operate&"','"&re_memo&"',"&username&","&re_clientid&")" else sql="insert into record(re_table,re_id,re_operate,re_memo,username,re_clientid) values('"&lcase(re_table)&"',"&re_id&",'"&re_operate&"','"&re_memo&"',"&username&","&re_clientid&")"
  # sql="insert into record(re_table,re_id,re_operate,re_memo,username,re_clientid) values('"&lcase(re_table)&"',"&re_id&",'"&re_operate&"','"&re_memo&"',"&username&","&re_clientid&")"
  # if return_id then
    # SimpleRecord=ExecuteCommand(sql,true)
  # else
    # call ExecuteCommand(sql,false)
  # end if
# end function

# '==================================================================  
# '函数：FormatTime   
# '功能：日期时间格式化   
# '参数：DateTime,日期时间   
# 'Template,格式化模板   
# '返回：格式化后的字串   
# '备注：模板标签注释   
# '　　　{Y}:年   
# '　　　{y}:2位年   
# '　　　{M}:月   
# '　　　{m}:补位月，例：01,02   
# '　　　{ME}:英文月份   
# '　　　{Me}:英文月份缩写   
# '　　　{D}:日   
# '　　　{d}:补位日   
# '　　　{H}:时   
# '　　　{h}:补位时   
# '　　　{N}:分   
# '　　　{n}:补位分   
# '　　　{S}:秒   
# '　　　{s}:补位秒   
# '　　　{W}:星期几英文   
# '　　　{w}:星期几英文缩写     
# '==================================================================  
  
# Function FormatTime(DateTime,Template)   
    # If (Not IsDate(DateTime)) or Template = "" Then  
        # FormatTime = Template   
        # Exit Function  
    # End If  
    # Dim dtmY,dtmM,dtmD,dtmH ,dtmN,dtmS,dtmW   
    # Dim arrFW,arrSW,arrFM,arrSM   
    # dtmY = Year(DateTime)   
    # dtmM = Month(DateTime)   
    # dtmD = Day(DateTime)   
    # dtmH  = Hour(DateTime)   
    # dtmN = Minute(DateTime)   
    # dtmS = Second(DateTime)   
    # dtmW = WeekDay(DateTime)   
    # arrFW = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")   
    # arrSW = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")   
    # arrFM = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")   
    # arrSM = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")     
    # Template = Replace(Template,"{Y}",dtmY)   
    # Template = Replace(Template,"{y}",Right(dtmY,2))   
    # Template = Replace(Template,"{M}",dtmM)   
    # Template = Replace(Template,"{m}",Right("00"&dtmM,2))   
    # Template = Replace(Template,"{ME}",arrFM(dtmM-1))   
    # Template = Replace(Template,"{Me}",arrSM(dtmM-1))   
    # Template = Replace(Template,"{D}",dtmD)   
    # Template = Replace(Template,"{d}",Right("00"&dtmD,2))   
    # Template = Replace(Template,"{H}",dtmH )   
    # Template = Replace(Template,"{h}",Right("00"&dtmH ,2))   
    # Template = Replace(Template,"{N}",dtmN)   
    # Template = Replace(Template,"{n}",Right("00"&dtmN,2))   
    # Template = Replace(Template,"{S}",dtmS)   
    # Template = Replace(Template,"{s}",Right("00"&dtmS,2))   
    # Template = Replace(Template,"{W}",arrFW(dtmW-1))   
    # Template = Replace(Template,"{w}",arrSW(dtmW-1))   
    # FormatTime = Template   
# End Function



